package com.nantian.logic.controller.mainControl.stuControl;

import com.nantian.logic.entity.mainEntity.stuEntity.StudentEntity;
import com.nantian.logic.repository.mainRepo.stuRepo.StudentRepository;
import com.nantian.logic.utils.UniversalResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value="/student")
public class StudentController {
    @Autowired StudentRepository stuRepo;
    @PostMapping(value = "/sel")
    public UniversalResult<List<StudentEntity>> findAllById(@RequestBody StudentEntity stuEnt){
        List<StudentEntity> list= stuRepo.findByUserid(stuEnt.getUserid());
        return new UniversalResult<>(UniversalResult.SUCCESS, "发起申请成功",list);
    }


    @PostMapping(value="/up")
    public UniversalResult save(@RequestBody StudentEntity stuEnt){
        stuRepo.save(stuEnt);
        return new UniversalResult(UniversalResult.SUCCESS, "发起申请成功",'1');
    }
}
